package com.dhj.yygh.controller;

import com.dhj.yygh.common.result.MyResult;
import com.dhj.yygh.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "oss 文件上传相关 api")
@RestController
@RequestMapping("/api/oss/file")
public class FileApiController {

    @Autowired
    private FileService fileService;

    @ApiOperation("上传文件到阿里云 oss")
    @PostMapping("/fileUpload")
    public MyResult<String> fileUpload(MultipartFile file) {

        String uploadUrl = fileService.upload(file);

        return MyResult.ok(uploadUrl);
    }
}
